home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Surfer: Getting Started
/
Internet Surfer - Getting Started (Wayzata Technology)(7231)(1995).bin
/
pc
/
mac
/
bonus
/
peter_le
/
finger_1
/
tokens
/
files.p
< prev
next >
Wrap
Text File
|
1991-12-02
|
2KB
|
75 lines
unit FILES;
interface
uses
ParameterDef;
procedure Main (var p: parameterRecord);
implementation
procedure Main (var p: parameterRecord);
var
rn, i: integer;
count, len: longInt;
s: str255;
oe, ooe: OSErr;
function MyFSRead (len: integer; buf: ptr): OSErr;
var
l: longInt;
oe: OSErr;
begin
l := len;
oe := FSRead(rn, l, buf);
if oe = eofErr then
oe := noErr;
if (oe = noErr) and (len <> l) then
oe := eofErr;
MyFSRead := oe;
end;
function MyFSOpen (s: str255): OSErr;
var
i: integer;
begin
for i := 1 to length(s) - 1 do { Disallow going back up the tree, obvious security breach }
if (s[i] = ':') and (s[i + 1] = ':') then
s[i] := '-';
MyFSOpen := FSOpen(s, 0, rn);
end;
begin
p.expandtokens := true;
s := p.param^;
if s = '' then
s := ':Preferences:Files:'
else
s := concat(s, ':');
if p.fingeredname^ = '' then
oe := MyFSOpen(concat(s, '@'))
else
oe := MyFSOpen(concat(s, p.fingeredname^));
if oe <> noErr then
oe := MyFSOpen(concat(s, '?'));
if oe = noErr then begin
oe := GetEOF(rn, count);
while (count > 0) and (oe = noErr) do begin
if count > 256 then
len := 256
else
len := count;
oe := MyFSRead(len, @s);
count := count - len;
if len > p.hlength - p.offset then
len := p.hlength - p.offset;
if len > 0 then begin
BlockMove(@s, ptr(longInt(p.fingeroutput^) + p.offset), len);
p.offset := p.offset + len;
end
else
oe := eofErr;
end;
ooe := FSClose(rn);
end;
end;
end.